package com.lm.ledger.action;

import java.util.ArrayList;
import java.util.List;

import com.lm.ledger.exception.LedgerException;
import com.lm.ledger.service.TransactionService;
import com.lm.ledger.service.TransactionServiceImp;
import com.lm.ledger.utill.Account;
import com.opensymphony.xwork2.ActionSupport;

public class ApproveTransaction extends TrxAction{

	public String execute() throws Exception {
		System.out.println("Validating login execute method");		
			return SUCCESS;		
	}
	private List accounts;
	private Account account;

	TransactionService service = new TransactionServiceImp();
		
	public String appTrx(){
		System.out.println("editTrx called----aaa----------");
		System.out.println("form id ---- "+getFormId());
		Account acc = service.getAccountForFormId(getFormId());
		setValues(acc);
   	 return SUCCESS;
   }
	
	public List getAccounts() {
		return accounts;
	}
	public void setAccounts(List accounts) {
		this.accounts = accounts;
	}
	public Account getAccount() {
		return account;
	}
	public void setAccount(Account account) {
		this.account = account;
	}
	public String getTrxToApprove(){
		System.out.println("HI Vipul.. you are great...");
	
			setLocations(service.getLocations(getUser().getUserId()));
	
		accounts = service.searchApproveTrx(getUser().getUserId());
   	 return SUCCESS;
   }
	
	public String searchApproveTrx(){
		System.out.println("searchApproveTrx ---------");
		System.out.println("form id --- "+getFormId());
		System.out.println("locationId "+getLocId());
		System.out.println("getPersonId "+getPersonId());
	
			setLocations(service.getLocations(getUser().getUserId()));
		
		setAccounts(service.searchList(getAccountDetail(), getUser().getUserId(), "approve"));
   	 return SUCCESS;
   }
	public String saveApproveTrx(){
		System.out.println("saveApproveTrx ......... ");
		System.out.println("status ---  "+getStatus());
		System.out.println("fomr id ---"+getFormId());
		Account account = getAccountDetail();
		account.setAuthId(getUser().getUserId().toString());
		account.setStatus("Y");
		//if("true".equals(getStatus())){
		//	System.out.println("states is ture");
		service.approveTrx(account);
		accounts = service.searchApproveTrx(getUser().getUserId());
		return SUCCESS;
		/*}else{
			return "return";
		}*/
   }

}
